package 笔试强训;
import java.util.*;
public class Text2 {
    //题目: 笔试强训day34第二题 :kotori和迷宫
    //算法 : bfs
    public static int N = 40;
    public static int x1,y1;  //记录起始位置
    public static int n,m;
    public static char[][] arr = new char[N][N];
    public static int[][] dist = new int[N][N];

    public static int[] dx = {1,-1,0,0} ;
    public static int[] dy = {0,0,1,-1};;  // 向量数组


    public static void bfs() {
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                //初始化 ret  为-1 表示没遍历过 + 到不了
                dist[i][j] = -1;
            }
        }

        //搞一个队列
        Queue<int[]> q = new LinkedList<>();

        //先把起点位置加进队列
        q.add(new int[]{x1,y1});
        dist[x1][y1] = 0;
        while(!q.isEmpty()) {
            //拿出对头元素
            int[] tmp = q.poll();
            int a = tmp[0];
            int b = tmp[1];
            //上下左右搜索
            for(int i = 0; i < 4; i++) {
                int x = a + dx[i];
                int y = b + dy[i];
                if(x >= 0 && x < n && y >= 0 && y < m && arr[x][y] != '*' && dist[x][y] == -1) {
                    dist[x][y] = dist[a][b] + 1;
                    if(arr[x][y] != 'e') {
                        //加入队列
                        q.add(new int[]{x,y});
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        //输入
        n = in.nextInt();
        m = in.nextInt();

        for(int i = 0; i < n; i++) {
            char[] tmp = in.next().toCharArray();
            for(int j = 0; j < m; j++) {
                arr[i][j] = tmp[j];
                if(arr[i][j] == 'k') {
                    //找到出发口了
                    x1 = i;
                    y1 = j;
                }
            }
        }

        bfs();


        //我们要找出几个出口 且找出最短的
        int count = 0;
        int min = 1000;  //找最短的路径
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                if(arr[i][j] == 'e' && dist[i][j] != -1) {
                    //说明这个出口可以走到
                    count++;
                    min = Math.min(min,dist[i][j]);
                }
            }
        }



        //输出
        if(count == 0) {
            System.out.println(-1);
        }else {
            System.out.println(count + " " + min);
        }
    }

}
